// 题意：same as poj1744
// run: $exec < bfdiff.in
#include <iostream>

int const maxn = 30000;
int floor[maxn + 7];
int ans[maxn + 7];
int n, stop;

int next_floor(int time, int last_stop, int stoped_time)
{
	return (time - 10 * stoped_time + 16 * last_stop + 4) / 20 + 1;
}

int goto_ith_highest_stop_floor(int time, int stoped_time, int ith_floor)
{
	return (time - 10 * stoped_time + 20 * ith_floor + 4) / 24;
}

bool judge(int time)
{
	int next_stop = next_floor(time, 1, 0);
	int stoped_time = 0;
	for (int i = 0; i < n; i++) {
		if (floor[i] < next_stop) continue;
		int stop_floor = goto_ith_highest_stop_floor(time, stoped_time, floor[i]);
		if (stop_floor < floor[i]) return false; // FIXME
		ans[stoped_time] = stop_floor;
		next_stop = next_floor(time, stop_floor, stoped_time++);
	}
	stop = stoped_time;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	while (std::cin >> n && n) {
		for (int i = 0; i < n; i++) std::cin >> floor[i];
		int l = 0, r = (maxn - 1) * 4 + (maxn - 2) * 10;
		while (l + 1 <= r) {
			int mid = (l + r) / 2;
			if (judge(mid)) r = mid;
			else			l = mid + 1;
		}
		if (judge(l)) r = l;
		stop = 0;
		judge(r);
		std::cout << r << '\n';
		std::cout << stop;
		for (int i = 0; i < stop; i++) std::cout << ' ' << ans[i];
		std::cout << '\n';
	}
}

